////////////////////////////////////////////////////////////////////////////////////////////////////
//																								  //
//  Filename:    TreasureChamberGuts.h										                      //
//  Developer:   Ben Wardlow												                      //
//  Create date: 7/10/2006													                      //
//																			                      //
////////////////////////////////////////////////////////////////////////////////////////////////////
//																			                      //
//  Description: This is the class declaration for the slot gut of the Australian Slot machine    //
//  			 called Treasure Chamber.														  //
//																			                      //
////////////////////////////////////////////////////////////////////////////////////////////////////
//				Copyright (c) 2006 - Realtime Gaming.  All rights reserved.	                      //
////////////////////////////////////////////////////////////////////////////////////////////////////

#ifndef __TREASURE_CHAMBER_GUTS_H__
#define __TREASURE_CHAMBER_GUTS_H__

#pragma once

#include "slotguts.h"
#include "getrand.h"

class TreasureChamberGuts :
	public SlotGuts
{
	typedef SlotGuts super;

public:
	enum GutsRange
	{
		MIN = 3700,
		MAX = 3799
	};


private:

	#include "TreasureChamberCommon.h"

	// Helpful lookup arrays.
	static SpinResult m_aLineWinSpinResults[][6];
	static SpinResult m_aScatterWinSpinResults[6];

	// Inline functions that also do bounds checking to use with the arrays.
	static SpinResult lookupLineWinSpinResult( uint8 nIconType, uint8 nCount )
	{
		if ( nIconType < NUM_VALID_ICONS && nCount < 6 )
		{
			return m_aLineWinSpinResults[ nIconType ][ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}

	static SpinResult lookupScatterWinSpinResult( uint8 nCount )
	{
		if ( nCount < 6 )
		{
			return m_aScatterWinSpinResults[ nCount ];
		}

		ASSERT( false );
		return EVT_INVALID;
	}

public:

	TreasureChamberGuts(void);
	virtual ~TreasureChamberGuts(void);
	virtual void classifyStops( SpinLine* spinLine, uint8* stops, uint8 bet, uint8 line,
		uint8& rtnResult, uint8& multiplier );
	virtual void classifyScatters( SlotSpin* spin );
	virtual bool8 isValidGuts();
	virtual void getGameModeMultiplierAndNoteId (uint8& nGameModeMultiplier, uint8& nNoteId );

	bool8 load( Info *info );
	void allocateSubGameData();
	const SlotIcon* getIcon( uint8 gamemodeID, uint8 reelID, uint8 position ) const;

protected:

    typedef std::map< const SlotIcon*, SlotIcon*> SlotIconSubstitutionMap;
    SlotIconSubstitutionMap m_mapSubstitutionIcons;

    int32 m_nQuestionMarkScatter;

	void deallocateSubstitutionIcons();
	bool8 allocateSubstitutionIcons();
	void resetSubstitutions();
	void setSubstitution( uint8 nReel, const SlotIcon* pOldIcon, int32 nNewIconId );
	int32 getSubstitution( uint8 nReel ) const;
	void addSubstitutionIcon( const SlotIcon* icon );
	void preSpinClassifyResults( SlotSpin* spin );

	// Helper functions for classifyStops.
	SpinResult getManLineWinResult( uint8* stops ) const;
	bool doesManLineWinPayMore( SpinResult srMan, SpinResult srOther ) const;
	SpinResult getLineWinResultWithPossibleSubstitution( uint8* stops, uint8 testIcon,
		bool& bSubstitution, uint8& numLineWinIcons ) const;

	// Helper functions for classifyScatters.
	void tryForJackpot( SlotSpin* spin );
	SpinResult getScatterWinResult( SlotSpin* spin, int32& scatterPositions ) const;
	void evaluateScatterWin( SlotSpin* spin, SpinResult srScatterResult, int32 scatterPositions );
	void evaluateFeatureTrigger( SlotSpin* spin, SpinResult srFeatureTriggerResult, int32 featurePositions );
	uint8 getNumFeatureTriggerIcons( SlotSpin* spin, uint8 icon, int32& scatterPositions ) const;

	virtual void initDebugFunctionMap();

	enum
	{
		EVT_DEBUG_FUNCTION_QUESTION_FALCON = BEGIN_SUB_MODIFY_NEXT_RESULT_FUNCTION_RANGE,
		EVT_DEBUG_FUNCTION_QUESTION_JAGUAR,
		EVT_DEBUG_FUNCTION_QUESTION_WOMAN,
		EVT_DEBUG_FUNCTION_QUESTION_ROSE,
		EVT_DEBUG_FUNCTION_QUESTION_MAN,

		EVT_DEBUG_FUNCTION_QUESTION_REEL_1,
		EVT_DEBUG_FUNCTION_QUESTION_REEL_2,
		EVT_DEBUG_FUNCTION_QUESTION_REEL_3,
		EVT_DEBUG_FUNCTION_QUESTION_REEL_4,
		EVT_DEBUG_FUNCTION_QUESTION_REEL_5
	};

	void DebugFeature_QuestionFalcon( SlotSpin *spin );
	void DebugFeature_QuestionJaguar( SlotSpin *spin );
	void DebugFeature_QuestionWoman( SlotSpin *spin );
	void DebugFeature_QuestionRose( SlotSpin *spin );
	void DebugFeature_QuestionMan( SlotSpin *spin );

	void DebugFeature_QuestionReel1( SlotSpin *spin );
	void DebugFeature_QuestionReel2( SlotSpin *spin );
	void DebugFeature_QuestionReel3( SlotSpin *spin );
	void DebugFeature_QuestionReel4( SlotSpin *spin );
	void DebugFeature_QuestionReel5( SlotSpin *spin );

	static int g_nDebugQuestionMarkIndex;
    static int g_nDebugQuestionMarks[ 5 ];
};

#endif //__TREASURE_CHAMBER_GUTS_H__
